package edu.ycu.aladdin.web.api.crawler;

import edu.ycu.aladdin.collector.api.entity.CrawlerConfig;
import edu.ycu.aladdin.web.common.RestResponse;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author <a href="mailto:wangruihuano@gmail.com">王瑞环</a>
 * @since 2019-04-02 14:51
 */
@RequestMapping("/crawler/config")
public interface CrawlerConfigAPI {

    @RequestMapping(method = RequestMethod.POST)
    RestResponse addConfig(CrawlerConfig config);

    @RequestMapping(method = RequestMethod.POST, headers = "Content-Type=application/json; charset=UTF-8")
    RestResponse addConfigByJson(@RequestBody CrawlerConfig config);

    @RequestMapping(method = RequestMethod.GET)
    RestResponse getAll(Boolean withId);

    @CrossOrigin(value = "*", maxAge = 3600)
    @RequestMapping(value = "/default", method = RequestMethod.GET)
    RestResponse getDefaultConfig();

    @CrossOrigin(value = "*", maxAge = 3600)
    @RequestMapping(method = RequestMethod.DELETE)
    RestResponse delConfig(String id, CrawlerConfig config);
}
